package com.zhy.http.okhttp.request;

import com.zhy.http.okhttp.callback.Callback;
import com.zhy.http.okhttp.utils.Exceptions;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import okhttp3.Headers.Builder;
import okhttp3.Request;
import okhttp3.Request.Builder;
import okhttp3.RequestBody;

public abstract class OkHttpRequest
{
  protected Request.Builder builder = new Request.Builder();
  protected Map<String, String> headers;
  protected Map<String, String> params;
  protected Object tag;
  protected String url;

  protected OkHttpRequest(String paramString, Object paramObject, Map<String, String> paramMap1, Map<String, String> paramMap2)
  {
    this.url = paramString;
    this.tag = paramObject;
    this.params = paramMap1;
    this.headers = paramMap2;
    if (paramString == null)
      Exceptions.illegalArgument("url can not be null.");
  }

  private void prepareBuilder()
  {
    this.builder.url(this.url).tag(this.tag);
    appendHeaders();
  }

  protected void appendHeaders()
  {
    Headers.Builder localBuilder = new Headers.Builder();
    if ((this.headers == null) || (this.headers.isEmpty()))
      return;
    Iterator localIterator = this.headers.keySet().iterator();
    while (true)
    {
      if (!localIterator.hasNext())
      {
        this.builder.headers(localBuilder.build());
        return;
      }
      String str = (String)localIterator.next();
      localBuilder.add(str, (String)this.headers.get(str));
    }
  }

  public RequestCall build()
  {
    return new RequestCall(this);
  }

  protected abstract Request buildRequest(Request.Builder paramBuilder, RequestBody paramRequestBody);

  protected abstract RequestBody buildRequestBody();

  public Request generateRequest(Callback paramCallback)
  {
    RequestBody localRequestBody = wrapRequestBody(buildRequestBody(), paramCallback);
    prepareBuilder();
    return buildRequest(this.builder, localRequestBody);
  }

  public String toString()
  {
    return "OkHttpRequest{url='" + this.url + '\'' + ", tag=" + this.tag + ", params=" + this.params + ", headers=" + this.headers + '}';
  }

  protected RequestBody wrapRequestBody(RequestBody paramRequestBody, Callback paramCallback)
  {
    return paramRequestBody;
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.zhy.http.okhttp.request.OkHttpRequest
 * JD-Core Version:    0.6.2
 */